<template>
  <div>
    御剑乘风来,除魔天地间!====DDDD
    <img src="https://img.yzcdn.cn/vant/cat.jpeg" v-loaderr="" alt="" />
    <img src="https://img.yzcdn.cn/vant/ct.jpeg" v-loaderr="" alt="" />
    <div v-loading="list.length === 0"></div>
  </div>
</template>
<script>
import Img from "../../assets/logo.png";
export default {
  name: "",
  data() {
    return {
      list: [1],
    };
  },
  directives: {
    loading: {
      inserted(el) {
        el.classList.add("loading");
        el.innerHTML = "加载中...";
      },
      update(el) {
        setTimeout(() => {
          el.style.display = "none";
        }, 1000);
      },
    },
    loaderr: {
      inserted(el) {
       el.addEventListener("error", () => {
         el.src = Img; 
       })
      }
    }
  },
  created() {},
  mounted() {
    setTimeout(() => {
      this.list.push(2);
    },2000)
  },
  computed: {},
  methods: {
    p() {
      this.list.push(2);
    },
  },
};
</script>
<style lang='less'  scoped>
.loading {
  position: fixed;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  z-index: 999;
  background-color: rgba(0, 0, 0, 0.3);
  font-size: 50px;
  color: red;
  text-align: center;
  line-height: 100vh;
}
</style>
